package com.zxtc.wh.dao;

import com.zxtc.wh.pojo.resource.UserPojo;
import com.zxtc.wh.utils.SqlUtil;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.UUID;

/**
 * 操作数据库User表的数据访问对象(mysql实现)
 * 2017年4月5日17:28:59
 */
public class UserDaoMysqlImpl implements IUserDao {


    @Override
    public UserPojo create() {
        final String sqlCmd;

//        UUID userUUID = UUID.randomUUID();
//        String uuidStr = userUUID.toString();
//        sqlCmd = "INSERT INTO USER " +
//                "(user_uuid) " +
//                "VALUES" +
//                "(?)";
//
////        Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
////        Thread.currentThread().getState().
//
//
//        PreparedStatement statement = getStatement(sqlCmd);
//        try {
//            statement.setString(1, uuidStr);
//            int i = statement.executeUpdate();
//            if (i != 0) {
//                return getInstance(uuidStr);
//            }
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }

        return null;
    }

    @Override
    public UserPojo create(UserPojo data) {
        return null;
    }

    @Override
    public UserPojo insert(UserPojo userPojo) {
        final String sqlCmd = "INSERT INTO USER (user_uuid, user_uuid)" +
                "VALUES (?, ?)";
        return null;
    }

    @Override
    public UserPojo updateOrCreate(UserPojo data) {
        return null;
    }

    @Override
    public Boolean isExists(Long aLong) {
        return null;
    }

    @Override
    public UserPojo getInstance(Long aLong) {
        return null;
    }


    @Override
    public UserPojo update(UserPojo data) {
        return null;
    }

    @Override
    public void onError(Exception eMessage) {

    }

    private PreparedStatement getStatement(String sqlCommand) {
        try {
            return SqlUtil.getInstance().getStatement(sqlCommand);
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

}
